package com.pdg.android.splorr.data.enums;

public enum RoomDirection {
	NORTH,
	EAST,
	SOUTH,
	WEST;
	public RoomDirection next(){
		switch(this){
		case NORTH:
			return EAST;
		case EAST:
			return SOUTH;
		case SOUTH:
			return WEST;
		case WEST:
			return NORTH;
		default:
			return null;
		}
	}
	public RoomDirection previous(){
		switch(this){
		case NORTH:
			return WEST;
		case EAST:
			return NORTH;
		case SOUTH:
			return EAST;
		case WEST:
			return SOUTH;
		default:
			return null;
		}
	}
	public RoomDirection opposite(){
		switch(this){
		case NORTH:
			return SOUTH;
		case EAST:
			return WEST;
		case SOUTH:
			return NORTH;
		case WEST:
			return EAST;
		default:
			return null;
		}
	}
	public RoomDirection next(int steps){
		if(steps==0){
			return this;
		}else if(steps<0){
			return previous(-steps);
		}else{
			return next().next(steps-1);
		}
	}
	public RoomDirection previous(int steps){
		if(steps==0){
			return this;
		}else if(steps<0){
			return next(-steps);
		}else{
			return previous().previous(steps-1);
		}
	}
	public int nextColumn(int theStartColumn,int theStartRow){
		switch(this){
		case NORTH:
			return theStartColumn;
		case EAST:
			return theStartColumn+1;
		case SOUTH:
			return theStartColumn;
		case WEST:
			return theStartColumn-1;
		default:
			return theStartColumn;
		}
	}
	public int nextRow(int theStartColumn,int theStartRow){
		switch(this){
		case NORTH:
			return theStartRow-1;
		case EAST:
			return theStartRow;
		case SOUTH:
			return theStartRow+1;
		case WEST:
			return theStartRow;
		default:
			return theStartRow;
		}
	}
}
